package com.inifitness.message.service;

import java.util.List;

import com.inifitness.message.enums.MessageChannel;

import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

/**
 * TODO: (sunjinfeng 2024-05-29)
 *
 * @author sunjinfeng
 * @version 1.0.0
 * @since 2024-05-29 14:31
 */
@Component
@Log4j2
public class EventTemplateServiceImpl implements EventTemplateService {

  @Override
  public List<EventTemplate> findByEventCode(String eventCode) {
    EventTemplate template1 = new EventTemplate();
    template1.setId(0L);
    template1.setEventCode(eventCode);
    template1.setChannelType(MessageChannel.SMS.getValue());
    template1.setRecipient("${custom.mobile}");
    template1.setTemplate("用户:${username},登录系统，IP:${ip},时间:${time}");
    template1.setStoreId(0L);

    EventTemplate template2 = new EventTemplate();
    template2.setId(1L);
    template2.setEventCode(eventCode);
    template2.setChannelType(MessageChannel.INBOX.getValue());
    template2.setRecipient("${system.admin}");
    template2.setTemplate(
        "小斯@邦提醒您: 用户:${username},登录系统，IP:${ip},时间:${time}");
    template2.setStoreId(0L);

    EventTemplate template3 = new EventTemplate();
    template3.setId(1L);
    template3.setEventCode(eventCode);
    template3.setChannelType(MessageChannel.INBOX.getValue());
    template3.setRecipient("${custom.coachId}");
    template3.setTemplate("小斯@邦提醒您: 用户:${username},登录系统，IP:${ip},时间:${time}");
    template3.setStoreId(0L);

    EventTemplate template4 = new EventTemplate();
    template4.setId(1L);
    template4.setEventCode(eventCode);
    template4.setChannelType(MessageChannel.LOG.getValue());
    template4.setRecipient("${system.file}");
    template4.setTemplate("用户:${username},登录系统，IP:${ip},时间:${time}");
    template4.setStoreId(0L);

    EventTemplate template5 = new EventTemplate();
    template5.setId(1L);
    template5.setEventCode(eventCode);
    template5.setChannelType(MessageChannel.DANMAKU.getValue());
    template5.setRecipient("${system.todo}");
    template5.setTemplate("用户:${username},登录系统，IP:${ip},时间:${time}");
    template5.setStoreId(0L);

    EventTemplate template6 = new EventTemplate();
    template6.setId(1L);
    template6.setEventCode(eventCode);
    template6.setChannelType(MessageChannel.WECHAT_OFFICIAL_ACCOUNT.getValue());
    template6.setRecipient("${system.memberId}");
    template6.setTemplate("用户:${username},登录系统，IP:${ip},时间:${time}");
    template6.setStoreId(0L);

    EventTemplate template7 = new EventTemplate();
    template7.setId(1L);
    template7.setEventCode(eventCode);
    template7.setChannelType(MessageChannel.EMAIL.getValue());
    template7.setRecipient("${system.email}");
    template7.setTemplate("用户:${username},登录系统，IP:${ip},时间:${time}");
    template7.setStoreId(0L);

    EventTemplate template8 = new EventTemplate();
    template8.setId(1L);
    template8.setEventCode(eventCode);
    template8.setChannelType(MessageChannel.WEBSOCKET.getValue());
    template8.setRecipient("${system.email}");
    template8.setTemplate("用户:${username},登录系统，IP:${ip},时间:${time}");
    template8.setStoreId(0L);
    return List.of(template1, template2, template3, template4, template5, template6, template7,template8);
  }
}
